﻿var taskService = abp.services.app.task;

function editTask(id) {
    abp.ajax({
            url: "/tasks/edit",
            data: { "id": id },
            type: "GET",
            dataType: "html"
        })
        .done(function(data) {
            $("#edit").html(data);
            $("#editTask").modal("show");
        })
        .fail(function(data) {
            abp.notify.error('Something is wrong!');
        });
}

function deleteTask(id) {
    abp.message.confirm(
        "是否删除Id为" + id + "的任务信息",
        function(isConfirmed) {
            if (isConfirmed) {
                taskService.deleteTask(id)
                    .done(function() {
                        abp.notify.info("删除任务成功！");
                        getTaskList();
                    });
            }
        }
    );
}

function getTaskList() {
    var $taskStateCombobox = $('#TaskStateCombobox');
    var url = '/Tasks/GetList?state=' + $taskStateCombobox.val();
    abp.ajax({
            url: url,
            type: "GET",
            dataType: "html"
        })
        .done(function(data) {
            $("#taskList").html(data);
        });
}